<template>
    <div class="topic_page">
        <div class="topic" v-for="item in data" :key="item.id">
            <div class="topic_image">
                <img :src="item.scene_pic_url" alt="">
            </div>
            <div class="topic_text">
                <div class="topic_title">{{item.title}}</div>
                <div class="topic_subtitle">{{item.subtitle}}</div>
                <div class="top_b">{{Number(item.price_info).toFixed(2)}}</div>
            </div>
        </div>

        <div class="button">
            <van-button type="default" class="btn" @click="onClick(1)">上一页</van-button><van-button class="btn" type="default" @click="onClick(2)">下一页</van-button>
        </div>
    </div>
</template>

<script>
import {GetTopicList} from "../request/api"
export default {
  data() {
    return {
        data:[]
    };
  },
  created() {
      GetTopicList({
          page:1,
          size:10
      }).then(res=>{
          if(!res.errno==0)return;
          console.log(res.data);
          let {data}=res.data;
          this.data=data
      })
  },
  methods:{
      onClick(page){
          GetTopicList({
          page:page,
          size:10
      }).then(res=>{
          if(!res.errno==0)return;
          let {data}=res.data;
          this.data=data
      })
       document.body.scrollTop = document.documentElement.scrollTop = 0;
      }
  }
};
</script>
 
<style lang = "less" scoped>

.btn{
    width: 50%;
}
.topic {
  background-color: rgb(255, 255, 255);
  overflow: hidden;
  width: 100%;
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;

}
.topic .topic_image {
  width: 100%;
}
.topic .topic_image img {
  width: 100%;
  height: 200px;
}
.topic .topic_title {
  font-size: 18px;
  margin: 10px 0;
}
.topic .topic_subtitle {
  font-size: 16px;
  margin: 20px 0;
  color: #1f1f1f;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.topic_btn {
  text-align: center;
}
.topic_btn .btn1 {
  width: 185px;
  height: 45px;
}
.topic_page {
  padding-bottom: 60px;
  background-color: rgb(231, 231, 231);
}

</style>